from rest_framework import serializers

from apps.index.models import Content, Gedan, Gequ


class IndexSerializer(serializers.ModelSerializer):
    """首页轮播图"""
    id = serializers.CharField(label='id', required=True)
    image = serializers.CharField(label='图片', required=True)

    class Meta:
        model = Content
        fields = ('id', 'image')


class GequSerializer(serializers.ModelSerializer):
    '''首页歌曲'''
    id = serializers.CharField(label='id', required=True)
    songname = serializers.CharField(label='歌曲名字',required=True)
    url = serializers.CharField(label='歌曲链接', required=True)
    artist = serializers.CharField(label='歌手', required=True)
    image = serializers.CharField(label='图片', required=True)
    # data_set = serializers.StringRelatedField(label='歌单信息')

    class Meta:
        model = Gequ
        fields = ('id','songname','url','artist','image')

    # def __str__(self):
    #     return self.songname

class GedanSerializer_v2(serializers.ModelSerializer):
    '''首页歌单'''
    id = serializers.CharField(label='id', required=True)
    playlist = serializers.CharField(label='歌单名字', required=True)
    image = serializers.CharField(label='图片', required=True)
    # heroinfo_set = serializers.PrimaryKeyRelatedField(queryset=Gequ.objects.all(),many=True)
    # data_set = serializers.PrimaryKeyRelatedField(label='歌单信息', queryset=Gedan.objects.all())
    # gequ_set = GequSerializer(read_only=True, many=True)

    class Meta:
        model = Gedan
        fields = ('id', 'playlist', 'image')
